/**
 * Company : TIS.
 * Created By : Chatree Siangklom
 * Created On : Aug 21, 2013  5:35:01 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.database.dao
 * File Name : AbstractDao.java
 * TODO
 */
package com.tis.database.dao;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.criterion.Criterion;
import sap.business.enumeration.STAGING_STATUS;
import com.tis.database.entitys.staging.StampObject;

/**
 * @author Administrator
 *
 */
public interface AbstractDao <E, I extends Serializable> {
	
	E findById(I id);
	void save(E e);
	void save(List<E> e);   
    void saveOrUpdate(E e);
    void saveOrUpdate(List<E> e);
    void remove(E e);
    void remove(List<E> e);
    void delete(E e);
    void delete(List<E> e);
    List<E> findByCriteria(Criterion criterion);
    
    /**
     * 
     * @param MaxResults  0 = unlimit
     * @return
     */
    List<E> findByAll(int MaxResults);
    List<E> findHQLByQuery(String hql, HashMap<String, String> parameter);
    void SaveOrUpdateHQLByQuery(String hql, HashMap<String, String> parameter);
    List<E> findNameQuery(String queryName, HashMap<String, String> parameter);
    void SaveOrUpdateQueryName(String queryName, HashMap<String, String> parameter);
    BigDecimal NextSequence(String name) throws HibernateException, Exception;
    BigDecimal NextInstanceNo() throws HibernateException, Exception;
    Date getCurrentDatabaseDate() throws HibernateException, Exception;
    
    void StampUsedTime(StampObject stampObject, E e);    
    
    void StampUsedTimePROC(String instanceNo, Date procStartTime, Date procEndTime, E e) throws Exception;
    
    void StampUsedTimeSend(String instanceNo, Date sendUseStart, Date sendUseEnd, E e) throws Exception;
    
    void StampUsedTimePms(String instanceNo, Date pmsUseStart, Date pmsUseEnd, E e) throws Exception;
    
    void SaveErrorToStaging(String instanceNo, STAGING_STATUS Staging_STATUS, String error);
    
    List<E> findByInstanceNo(String instanceNo, E e) throws HibernateException, Exception;
    
}